import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { newsItem } from '@/types/news'
// 定义 Store
export const useNewsStore = defineStore(
  'news',
  () => {
    // 新闻信息
    const news = ref<newsItem>(
    )

    // 保存新闻信息
    const setNews = (val: newsItem) => {
      news.value = val
    }

    // 清理新闻信息
    const clearNews = () => {
      news.value = undefined
    }

    // 记得 return
    return {
      news,
      setNews,
      clearNews,
    }
  }
)
